package com.smart.manager.system.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.smart.common.entities.ajax.AjaxResult;
import com.smart.common.entities.constant.SmartConstant;
import com.smart.common.entities.core.Page;
import com.smart.manager.system.entities.body.RSystemScheduleApp;
import com.smart.manager.system.entities.models.SystemScheduleApp;
import com.smart.manager.system.repository.ScheduleAppRepository;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author Administrator
 */

@Api(tags = "任务管理")
@RestController
@RequestMapping(SmartConstant.MANAGER_API_PREFIX + "system/schedule/app")
@RequiredArgsConstructor
public class ScheduleAppApi {

    private final ScheduleAppRepository scheduleAppRepository;

    @GetMapping(value = "pageList")
    @ApiOperation(value = "查询程序")
    @SaCheckPermission("system:schedule:app:pageList")
    public AjaxResult<Page<SystemScheduleApp>> pageList(@Validated RSystemScheduleApp.SearchBody body) {
        Page<SystemScheduleApp> result = scheduleAppRepository.pageList(body);
        return AjaxResult.data(result);
    }


    @GetMapping(value = "scan")
    @ApiOperation(value = "扫描程序")
    @SaCheckPermission("system:schedule:app:scan")
    public AjaxResult< String> scan() {
         scheduleAppRepository.scan();
        return AjaxResult.success();
    }


}
